/*
    Data_LSST is actually not data ....
	The following fiducial values are taken from the column "2015F(CHM) (Plik)" of Table-1
	in ref https://arxiv.org/abs/1502.01589v1
*/

#include "ClassMC.hpp"

using namespace std;
using namespace imcmc;
using namespace imcmc::parser;

LSST_Forecast_WB::LSST_Forecast_WB(){
//  do nothing
}

LSST_Forecast_WB::~LSST_Forecast_WB(){
//  no nothing
}

void LSST_Forecast_WB::Init( string& lsst_dataset,
                             bool& use_WL,
                             bool& use_BAO ){

	data_info.GetInfo(lsst_dataset);

    if( use_BAO && (use_WL == false) ){
		imcmc_verbose(	MPI::COMM_WORLD.Get_rank(),
						"loading Fisher matrix from: LSST_BAO_FMatrix");
        FMatrixFile = Read::Read_String_from_File(lsst_dataset,"LSST_BAO_FMatrix");
	}

    if( (use_BAO == false) && use_WL ){
		imcmc_verbose(	MPI::COMM_WORLD.Get_rank(),
						"loading Fisher matrix from: LSST_WL_FMatrix");
        FMatrixFile = Read::Read_String_from_File(lsst_dataset,"LSST_WL_FMatrix");
	}

    if( use_BAO && use_WL ){
		imcmc_verbose(	MPI::COMM_WORLD.Get_rank(),
						"loading Fisher matrix from: LSST_WB_FMatrix");
        FMatrixFile = Read::Read_String_from_File(lsst_dataset,"LSST_WB_FMatrix");
	}

    Params_fid  = arma::zeros(11);
    // Params_fid  = arma::zeros(10);

    //  fiducal values are manully set here.
    // Params(0) = full_params["w0_fld"];
    // Params(1) = full_params["wa_fld"];
    // Params(2) = Omega_m*(H0/100.)*(H0/100.);
    // Params(3) = full_params["omegabh2"];
    // Params(4) = 0.01*full_params["100*theta_s"];
    // Params(5) = full_params["omegak"];  // be careful!!
    // Params(6) = full_params["tau_reio"];
    // Params(7) = full_params["Yp"];
    // Params(8) = full_params["n_s"];
    // Params(9) = full_params["alpha_s"];
    // Params(10)= full_params["ln(10^10A_s)"]/log(10.)/10.0;

//  TODO: these fiducial values will be saved in a txt file, not to be fixed any more...
    Params_fid(0) =-1.0;
    Params_fid(1) = 0.0;
    Params_fid(2) = 0.1199+0.0222;
    Params_fid(3) = 0.0222;
    Params_fid(4) = 0.0104086;
    Params_fid(5) = 0.0;
    Params_fid(6) = 0.078;
    Params_fid(7) = 0.255;
    //Params_fid(7) = 0.2475;
    Params_fid(8) = 0.9652;
    Params_fid(9) = 0.0;
    Params_fid(10)= log(2.2e-9);

    // cout << "reading LSST FisherMatrix: " << FMatrixFile << endl;
    FisherMatrix.load(FMatrixFile, arma::auto_detect);

// exit(0);

	if( FisherMatrix.n_rows != 11 || FisherMatrix.n_cols != 11 ){
		throw runtime_error("## error in reading LSST Fisher Matrix !\n");
	}

}
